`
https://leetcode.cn/problems/first-unique-character-in-a-string/
`

/**
 * @param {string} s
 * @return {number}
 */
var firstUniqChar = function (s) {
  const count = new Array(26).fill(0)
  for (const c of s) {
    const idx = c.charCodeAt(0) - 'a'.charCodeAt(0)
    count[idx]++
  }

  for (let i = 0; i < s.length; i++) {
    const c = s[i]
    const idx = c.charCodeAt(0) - 'a'.charCodeAt(0)
    if (count[idx] === 1) {
      return i
    }
  }

  return -1
};